package 图书管理项目.oprations;

import 图书管理项目.Book;
import 图书管理项目.Dao.BookDao;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work() {
        System.out.println("新增书籍！");
        System.out.println("请输入书名");
        Scanner scanner=new Scanner(System.in);
        String bookname=scanner.next();
        System.out.println("请输入作者");
        String author=scanner.next();
        System.out.println("请输入价格");
        int price=scanner.nextInt();
        System.out.println("请输入类别");
        String type=scanner.next();
        //新增的书籍默认为未借出

        Book book=new Book();
        book.setName(bookname);
        book.setAuthor(author);
        book.setPrice(price);
        book.setType(type);

        BookDao bookDao=new BookDao();
        boolean ret=bookDao.add(book);
        if (ret) {
            System.out.println("新增书籍成功");
        }else {
            System.out.println("新增书籍失败");
        }
    }
}
